package de.ff7rl.ui;

import java.awt.BorderLayout;
import java.awt.Color;

import javax.swing.JFrame;

import de.ff7rl.core.Game;
import de.ff7rl.core.GameInfo;
import de.ff7rl.core.gamestate.GameState;

public class UserInterface extends JFrame {

  private final Terminal terminal;
  private final Game game;

  public UserInterface() {
    super(String.format("%s %s", GameInfo.getName(), GameInfo.getVersion()));
    game = new Game();
    terminal = new TerminalComponent(12, 40, 120, Color.WHITE, Color.BLACK);
    game.initialize(terminal);
    game.newGameState(GameState.INTRO);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLayout(new BorderLayout());
    add((TerminalComponent) terminal, BorderLayout.CENTER);
    pack();
    setResizable(false);
    setLocationRelativeTo(null);
    setVisible(true);
    addKeyListener(new UserInterfaceKeyListener(game));
  }

}
